#include "World.h"

World* World::_instance = 0;

World::World() {
	BZRC* com = Remote::instance();

	// TODO: This may not be the best way of updating these
	_constants.clear();
	_flags.clear();
	_tanks.clear();
	_obstacles.clear();
	_other_tanks.clear();
	_shots.clear();
	_teams.clear();

	com->get_constants(&_constants);
	com->get_obstacles(&_obstacles);
	com->get_teams(&_teams);
	com->get_lots_o_stuff(&_tanks, &_other_tanks, &_flags, &_shots);
}


World::~World() {
}

World* World::instance() {
	if (!_instance)
		_instance = new World();

	return _instance;
}

void World::update() {
	BZRC* com = Remote::instance();

	_flags.clear();
	_tanks.clear();
	_other_tanks.clear();
	_shots.clear();

	com->get_lots_o_stuff(&_tanks, &_other_tanks, &_flags, &_shots);
}

vector <constant_t> & World::constants() {
	return _constants;
}

vector <flag_t> & World::flags() {
	return _flags;
}

vector <tank_t> & World::tanks() {
	return _tanks;
}

vector <obstacle_t> & World::obstacles() {
	return _obstacles;
}

vector <otank_t> & World::other_tanks() {
	return _other_tanks;
}

vector <shot_t> & World::shots() {
	return _shots;
}

vector <team_t> & World::teams() {
	return _teams;
}